﻿<Window x:Class="MineSweeper.Windows.Statistics"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:p="clr-namespace:MineSweeper.Properties"
        xmlns:data="clr-namespace:MineSweeper.Data"
        xmlns:commands="clr-namespace:MineSweeper.Commands"
        xmlns:cm="clr-namespace:System.ComponentModel;assembly=WindowsBase"
        Title="Statistics" Height="194" Width="594"
        xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" 
        WindowStartupLocation="CenterScreen"
        Name="statisticsWindow"
        Style="{StaticResource optionWindowBackgroundStyle}">
    <Window.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="FontSize" Value="4" />
        </Style>
        <Style TargetType="Button">
            <Setter Property="Width" Value="50" />
            <Setter Property="Height" Value="9" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Bottom" />
            <Setter Property="FontSize" Value="4" />
            <Setter Property="Padding" Value="0" />
        </Style>
    </Window.Resources>
    <Window.DataContext>
        <ObjectDataProvider ObjectType="{x:Type data:DifficultyManager}"/>
    </Window.DataContext>
    <Grid>
        <Grid.DataContext>
            <Binding Path="DifficultyList"/>
        </Grid.DataContext>
        <Viewbox>
            <Grid VerticalAlignment="Bottom" Height="60" Width="221">
                <Grid.RowDefinitions>
                    <RowDefinition Height="42" />
                    <RowDefinition Height="15" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="58" />
                    <ColumnDefinition Width="83" />
                    <ColumnDefinition Width="76" />
                </Grid.ColumnDefinitions>
                <StackPanel>
                    <ListBox
                        x:Name="difficultyLB"  HorizontalAlignment="Left" Margin="5,2,0,2" BorderThickness=".5"
                        Width="50" Height="25" Foreground="Black" ItemsSource="{Binding}" 
                        IsSynchronizedWithCurrentItem="True">
                        <ListBox.ItemTemplate>
                            <DataTemplate DataType="Difficulty">
                                <StackPanel Orientation="Vertical">
                                    <TextBlock Text="{Binding Name, Mode=OneTime}" 
                                               FontSize="4" Foreground="Black"/>
                                </StackPanel>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </StackPanel>
                <GroupBox Grid.Row="0"  Grid.Column="1" Header="Best Times" Height="40" 
                          FontSize="4" VerticalAlignment="Top" BorderThickness=".25" Margin="2,0,3,0">
                    <Grid Height="auto">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <ListBox Name="lb1" BorderBrush="Transparent" FontSize="4" Margin="0" VerticalContentAlignment="Stretch"
                             Background="Transparent" Foreground="Black" Height="33" Padding="0" Grid.Column="0"
                             ScrollViewer.HorizontalScrollBarVisibility="Hidden" HorizontalAlignment="Left"
                             ItemsSource="{Binding Path=/Times, UpdateSourceTrigger=Explicit}" IsSynchronizedWithCurrentItem="True"
                             ScrollViewer.VerticalScrollBarVisibility="Hidden" />
                    </Grid>
                </GroupBox>
                <Grid Grid.Row="0" Grid.Column="2">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                        <RowDefinition Height="auto" />
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Row="0" Margin=".45">
                        <TextBlock.Text>
                            <Binding Path="/Played" StringFormat="Games Played: {0}" UpdateSourceTrigger="PropertyChanged"/>
                        </TextBlock.Text>
                    </TextBlock>
                    <TextBlock Grid.Row="1" Margin=".45">
                        <TextBlock.Text>
                            <Binding Path="/Wins" StringFormat="Games Won: {0}" UpdateSourceTrigger="PropertyChanged"/>
                        </TextBlock.Text>
                    </TextBlock>
                    <TextBlock Grid.Row="2" Margin=".45">
                        <TextBlock.Text>
                            <Binding Path="/WinPercent" StringFormat="Win Percentage: {0} %" UpdateSourceTrigger="PropertyChanged"/>
                        </TextBlock.Text>
                    </TextBlock>
                    <TextBlock Grid.Row="3" Margin=".45">
                        <TextBlock.Text>
                            <Binding Path="/WinStreak" StringFormat="Longest Winning Streak: {0}" UpdateSourceTrigger="PropertyChanged"/>
                        </TextBlock.Text>
                    </TextBlock>
                    <TextBlock Grid.Row="4" Margin=".45">
                        <TextBlock.Text>
                            <Binding Path="/LossStreak" StringFormat="Longest Losing Streak: {0}" UpdateSourceTrigger="PropertyChanged"/>
                        </TextBlock.Text>
                    </TextBlock>
                    <TextBlock Grid.Row="5" Margin=".45">
                        <TextBlock.Text>
                            <Binding Path="/Current" StringFormat="Current Streak: {0}" UpdateSourceTrigger="PropertyChanged"/>
                        </TextBlock.Text>
                    </TextBlock>
                </Grid>
                <Grid Grid.Row="1" Grid.ColumnSpan="3" Height="15" VerticalAlignment="Bottom">
                    <Grid.RowDefinitions>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="105" />
                        <ColumnDefinition Width="auto" />
                        <ColumnDefinition Width="auto" />
                    </Grid.ColumnDefinitions>
                    <Button Grid.Row="1" Grid.Column="1" Content="Close" Margin="2,2,2,4">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <ei:CallMethodAction TargetObject="{Binding ElementName=statisticsWindow}" MethodName="Close"/>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <Button Grid.Row="1" Grid.Column="2" Content="Reset"
                            Command="{x:Static commands:GameCommands.ShowResetDialog}" 
                            Margin="2,2,10,4" CommandParameter="{Binding Path=Parent}" />
                </Grid>
            </Grid>
        </Viewbox>
    </Grid>
</Window>
